package com.openthree.userport.service.impl;

import com.example.demo.util.JwtUtil;
import com.openthree.common.oss.CloudStorageService;
import com.openthree.common.oss.OSSFactory;
import com.openthree.userport.api.PublishPortApi;
import com.openthree.userport.service.daoservice.PortService;
import com.openthree.userport.vo.FormData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 发布作品 xrx
 */
@RestController
public class PublishPortImpl implements PublishPortApi {
    @Autowired
    private PortService portService;

    @Override
    public String test(MultipartFile[] files) {
        return "1212";
    }

    /**
     * 保存作品图片信息
     * @param file
     * @param formData
     * @return
     * @throws IOException
     */
    @Override
    public String uploadPortImage(MultipartFile file, FormData formData) throws Exception {
        portService.savePortImages(formData,file);
        return formData.getPortId();
    }

    /**
     * 发布作品
     * @param formData
     * @throws Exception
     */
    @Override
    public String publishPort(FormData formData) throws Exception {
        return portService.saveUserPort(formData);

    }
}
